require "import"
import "tools"
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS).setStatusBarColor(0xff4DB6AC)
activity.setContentView("aEcho_")
aEcho.background=btBackground
oDir.text=LUA_SD.."/avHandle/output/"
iDir.onClick=function()
  ChoiceFile(LUA_SD,function(dir)
    iDir.text=dir
    dialogPlayer(dir)
  end)
end
oDir.onClick=function()
  ChoicePath(LUA_SD,function(dir)
    oDir.text=dir.."/"
  end)
end
aEcho.onClick=function()
  if File(iDir.text).exists()
    if filename.text~=""
      if in_gain.text~="" and out_gain.text~="" and delays.text~="" and decays.text~=""
        local s=tostring(File(iDir.text).getName())
        s=s:sub(s:find("%."),#s)
        if s==".mp3"
          s=".aac"
        end
        local cmd="-i "..iDir.text.." -af aecho="..in_gain.text..":"..out_gain.text..":"..delays.text..":"..decays.text.." -y "..oDir.text..filename.text..s
        activity.newActivity("handle",{cmd})
       else
        print("请输入完整")
      end
     else
      print("请输入文件名")
    end
   else
    print("文件不存在")
  end
end

adp=ArrayAdapter(activity,android.R.layout.simple_spinner_item, String({"未选择","标准","方案一","方案二","方案三","方案四","方案五"}))
adp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
sp.Adapter=adp

sp.onItemSelected=function( a, v, i, l)
  if v.text=="未选择"
    in_gain.text=""
    out_gain.text=""
    delays.text=""
    decays.text=""
  end
  if v.text=="标准"
    in_gain.text="0.6"
    out_gain.text="0.3"
    delays.text="1000"
    decays.text="0.5"
  end
  if v.text=="方案一"
    in_gain.text="0.8"
    out_gain.text="0.88"
    delays.text="60"
    decays.text="0.4"
  end
  if v.text=="方案二"
    in_gain.text="0.8"
    out_gain.text="0.9"
    delays.text="500"
    decays.text="0.3"
  end
  if v.text=="方案三"
    in_gain.text="0.8"
    out_gain.text="0.88"
    delays.text="6"
    decays.text="0.4"
  end
  if v.text=="方案四"
    in_gain.text="0.8"
    out_gain.text="0.9"
    delays.text="1000"
    decays.text="0.3"
  end
  if v.text=="方案五"
    in_gain.text="0.8"
    out_gain.text="0.9"
    delays.text="1000|1800"
    decays.text="0.3|0.25"
  end
end